package store.lunangangster.bpmn.util;

import com.sun.org.slf4j.internal.Logger;
import com.sun.org.slf4j.internal.LoggerFactory;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamReader;

public class XmlStreamUtil {

  private static final Logger log = LoggerFactory.getLogger(XmlStreamUtil.class);

  public static String toNext(XMLStreamReader xsr) {
    try {
      while (xsr.hasNext()) {
        int next = xsr.next();
        switch (next) {
          case XMLStreamConstants.START_ELEMENT:
            return xsr.getLocalName();
          case XMLStreamConstants.END_ELEMENT:
          case XMLStreamConstants.END_DOCUMENT:
            return null;
        }
      }
    } catch (Exception e) {
      log.error("xml解析错误", e);
    }
    return null;
  }
}
